<template>
  <div class="full-box shadow-box padding-box">
    <OperateCollection
      :showAdd="true"
      @search="initData"
      @add="linkTo(`commonForm/${tableName}/0`)"
    >
      <template #condition>
        <div class="condition-item">
          <el-input
            v-model="queryParams.project_name"
            placeholder="按项目名称关键字查询"
            clearable
          ></el-input>
        </div>
        <div v-if="isAdmin == 1" class="condition-item">
          <DeptCascader
            :options="dept"
            :defaultChecked.sync="queryParams.responsible_unit_id"
            @change="changeDept"
          ></DeptCascader>
        </div>
        <div class="condition-item">
          <el-date-picker
            v-model="queryParams.start_notice_date"
            type="date"
            placeholder="开始日期"
            format="yyyy 年 MM 月 dd 日"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </div>
        <div class="condition-item">
          <el-date-picker
            v-model="queryParams.end_notice_date"
            type="date"
            placeholder="结束日期"
            format="yyyy 年 MM 月 dd 日"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </div>
      </template>
    </OperateCollection>
    <div class="table-wrapper">
      <BaseTable
        :columns="columns"
        :showSort="true"
        :tableData="tableData"
        :pages="{
          show: true,
          count: count
        }"
        :operate="{
          show: true,
          width: 150
        }"
        @pagination="pageChange"
      >
        <template #operate="{ current }">
          <el-button
            type="primary"
            size="mini"
            @click="linkTo(`commonForm/${tableName}/${current.row.id}`)"
            >详情</el-button
          >
        </template>
      </BaseTable>
    </div>
  </div>
</template>

<script>
import BaseTable from '@/components/Common/BaseTable.vue';
import OperateCollection from './components/OperateCollection.vue';
import LinkTo from '@/mixins/LinkTo';
import { getBidList } from '@/api/WorkCollection/Index';
import commonList from '@/mixins/commonList';

import queryItem from './components/queryItem';
import DeptCascader from '@/components/Common/DeptCascader.vue';
export default {
  mixins: [LinkTo, commonList, queryItem],
  components: { BaseTable, OperateCollection, DeptCascader },
  data() {
    return {
      columns: columns,
      tableData: [],
      count: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        project_id: '',
        project_name: '',
        responsible_unit_id: '',
        start_notice_date: '',
        end_notice_date: ''
      },
      tableName: 't_bid'
    };
  },
  methods: {
    initData() {
      getBidList(this.queryParams).then((res) => {
        if (res.code == 0) {
          this.tableData = res.data;
          this.count = res.num;
        }
      });
    },
    pageChange(val) {
      this.queryParams.pageNum = val.pageNum;
      this.queryParams.pageSize = val.pageSize;
      this.initData();
    }
  },
  created() {
    let id = this.$route.query.id;
    if (id) this.queryParams.project_id = id;
    this.initData();
  }
};

const columns = [
  {
    prop: 'project_name',
    label: '项目名称',
    width: '',
    minWidth: '200',
    align: ''
  },
  {
    prop: 'bid_agency_name',
    label: '代理机构',
    width: '',
    minWidth: '100',
    align: ''
  },
  {
    prop: 'notice_title',
    label: '公告标题',
    width: '',
    minWidth: '200',
    align: ''
  },
  {
    prop: 'notice_date',
    label: '公告日期',
    width: '',
    minWidth: '100',
    align: ''
  },
  {
    prop: 'win_enterprise',
    label: '中标单位',
    width: '',
    minWidth: '200',
    align: ''
  }
];
</script>

<style lang="scss" scoped=""></style>
